<?php
/* @var $this IngatlanController */
/* @var $model Ingatlan */
/* @var $form CActiveForm */
?>

<div class="form">

    <?php
    $form = $this->beginWidget('CActiveForm', array(
        'id' => 'ingatlan-form',
        'enableAjaxValidation' => false,
            ));
    ?>

    <p class="note">Fields with <span class="required">*</span> are required.</p>

    <?php echo $form->errorSummary($model); ?>
    <table>
        <tr>
            <td><div class="row">
        <?php
        echo "<b>Ingatlan kategoria</b></br>";
        ?>
        <?php
        $ingatlan_kategoriak = IngatlanKategoria::model()->findAll();
        echo CHtml::dropDownList('ing_kat', 'ID', CHtml::listData($ingatlan_kategoriak, 'ID', 'kategoria_nev'), array(
            'empty' => '(Select a category)',
            'options' => array(
                ($model->varos_ID == null) ? '0' : ($model->ingatlanKategorias[0]->ID) => array('selected' => true)
            )
        ));
        ?>
    </div></td>
            <td> <div class="row">
        <?php echo $form->labelEx($model, 'ingatlan_tipus'); ?>
        <?php
        $ingatlan_tipus = IngatlanTipus::model()->findAll();
        //print_r($ingatlan_kategoriak);
        echo CHtml::dropDownList('ing_tip', 'ID', CHtml::listData($ingatlan_tipus, 'ID', 'tipus_nev'), array('empty' => '(Select a type)',
            'options' => array(
                ($model->varos_ID == null) ? '0' : ($model->ingatlanTipus->ID) => array('selected' => true)
                )));
        ?>
        <?php echo $form->error($model, 'ingatlan_tipus_ID'); ?>
    </div></td>
        </tr>
        <tr>
            <td> <div class = "row">
        <?php echo $form->labelEx($model, 'varos'); ?>
        <?php
        $varos = Varos::model()->findAll();
        //print_r($ingatlan_kategoriak);
        echo CHtml::dropDownList('varos', 'ID', CHtml::listData($varos, 'ID', 'varos_nev'), array('empty' => '(Select a type)',
            'options' => array(
                ($model->varos_ID == null) ? '0' : ($model->varos_ID) => array('selected' => true)
                )));
        ?>
        <?php echo $form->error($model, 'varos_ID'); ?>
    </div></td>
            <td> <div class="row">
        <?php echo $form->labelEx($model, 'publikus'); ?>
        <?php
        echo CHtml::dropDownList('public', 'public', array('1' => 'Igen', '0' => 'Nem'), array(
            'options' => array(
                ($model->varos_ID == null) ? '0' : ($model->publikus) => array('selected' => true)
                )));
        ?>
        <?php echo $form->error($model, 'publikus'); ?>

    </div></td>
        </tr>
        
        <tr>
            <td> <div class="row">
        <?php echo $form->labelEx($model, 'eladva'); ?>
        <?php
        echo CHtml::dropDownList('eladva', 'eladva', array('1' => 'Igen', '0' => 'Nem'), array(
            'options' => array(
                ($model->varos_ID == null) ? '0' : ($model->eladva) => array('selected' => true)
                )));
        ?>
        <?php echo $form->error($model, 'eladva'); ?>
    </div></td>
            <td> <div class="row">
        <?php echo $form->labelEx($model, 'cim'); ?>
        <?php echo CHtml::textField('cim'); ?>
        <?php echo $form->error($model, 'cim'); ?>
    </div></td>
        </tr>
        
        <tr>
            <td><div class="row">
        <?php echo $form->labelEx($model, 'iranyitoszam'); ?>
        <?php echo CHtml::textField('iranyitoszam', ($model->varos_ID == null) ? '' : $model->iranyitoszam); ?>
        <?php echo $form->error($model, 'iranyitoszam'); ?>
    </div></td>
            <td><div class="row">
        <?php echo $form->labelEx($model, 'ar'); ?>
        <?php echo CHtml::textField('ar', ($model->varos_ID == null) ? '' : $model->ar); ?>
        <?php echo $form->error($model, 'ar'); ?>
    </div></td>
        </tr>
        
        <tr>
            <td><div class="row">
        <?php echo $form->labelEx($model, 'leiras'); ?>
        <?php echo CHtml::textArea('leiras', ($model->varos_ID == null) ? '' : $model->leiras, array('rows' => 10, 'cols' => 60)); ?>
        <?php echo $form->error($model, 'leiras'); ?>
    </div></td>
        </tr>
        
    </table>

    <div class="row">
        <?php
        echo "<b>Ingatlan jellemzők</b></br>";
        ?>
        <?php
        $ingatlan_jellemzok = IngatlanJellemzo::model()->findAll();
        echo CHtml::activeCheckboxList(
                $model, 'ID', CHtml::listData(IngatlanJellemzo::model()->findAll(), 'ID', 'jellemzo'), array('template'=>'<tr><td >{label}</td><td>{input}</td></tr>')
        );
        ?>
    </div>

    <div class="row buttons">
<?php echo CHtml::submitButton($model->isNewRecord ? 'Létrehozás' : 'Mentés'); ?>
    </div>

<?php $this->endWidget(); ?>

</div><!-- form -->